/*
 * BPlusNode.h
 *
 *  Created on: 09/11/2013
 *      Author: gastonmontes
 */

#ifndef BPLUSNODE_H_
#define BPLUSNODE_H_

#include <iterator>
#include <vector>

#include "../Types.h"
#include "../IEvaluator.h"
#include "../ISerializable.h"

template<class T>
class BPlusNode : public ISerializable{

private:
	typedef std::vector<T*> RecordList;
	RecordList records;
	typename RecordList::const_iterator position;
	BigInt level;
	BigInt elementsCount;

public:

	// Constructor and destructor.
	BPlusNode(BigInt nodeNivel);
	virtual ~BPlusNode();

	// AMB methods.
	void add(const T& record);
	bool find(T& record, const IEvaluator<T>& eval);
	bool next(T& record);
	bool remove(const T& record);
	void clear();

	// Level methods.
	void upLevel();
	void downLevel();

	// ISerializable methods.
	virtual BigInt size() const;
	virtual void serialize(ISerializer& serializer) const;
	virtual void unserialize(IUnserializer& unserializer);
};

#endif /* BPLUSNODE_H_ */
